home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / KEYBOARD.SWG / 0014_Read Keyboard STATE Keys.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  2KB  |  75 lines

  1. {
  2. >Can someone give me some code to make the lights Num lock/caps
  3. >lock/scroll lock keys to turn on?
  4. }
  5.  
  6. Program KeySet;
  7. Const
  8.   CapsState   = $40; { Mask For Caps Lock state }
  9.   NumState    = $20; { Mask For Num Lock state }
  10.   ScrollState = $10; { Mask For Scroll Lock state }
  11. Var
  12.   Kb : Byte Absolute $0040:$0017; { Address of keyboard flags }
  13.   I  : Byte;
  14.   S  : String;
  15. begin
  16.   if ParamCount = 0 then
  17.   begin
  18.     WriteLn;
  19.     WriteLn(' Command line options:');
  20.     WriteLn;
  21.     WriteLn(' C toggle Cap lock state');
  22.     WriteLn(' N toggle Num lock state');
  23.     WriteLn(' S toggle Scroll lock state');
  24.     WriteLn(' Add + to turn on and - to turn off');
  25.     Halt(1);
  26.   end;
  27.   For I := 1 to ParamCount Do
  28.   begin
  29.     S := ParamStr(I);
  30.     S[1] := UpCase(S[1]);
  31.     { toggle Caps Lock }
  32.     if S = 'C' then Kb := Kb xor CapsState;
  33.     { toggle Num Lock }
  34.     if S = 'N' then Kb := Kb xor NumState;
  35.     { toggle Scroll Lock }
  36.     if S = 'S' then Kb := Kb xor ScrollState;
  37.     { Set Caps Lock on }
  38.     if S = 'C+' then Kb := Kb or CapsState;
  39.     { Set Num Lock on }
  40.     if S = 'N+' then Kb := Kb or NumState;
  41.     { Set Scroll Lock on }
  42.     if S = 'S+' then Kb := Kb or ScrollState;
  43.     { Set Caps Lock off }
  44.     if S = 'C-' then Kb := Kb and not (CapsState or not Kb);
  45.     { Set Num Lock off }
  46.     if S = 'N-' then Kb := Kb and not (NumState or not Kb);
  47.     { Set Scroll Lock off }
  48.     if S = 'S-' then Kb := Kb and not (ScrollState or not Kb);
  49.   end;
  50.  
  51.   Write('Caps Lock  : ');
  52.   if (Kb and CapsState) = CapsState then
  53.     WriteLn('ON')
  54.   else
  55.     WriteLn('ofF');
  56.  
  57.   Write('Num Lock   : ');
  58.   if (Kb and NumState) = NumState then
  59.     WriteLn('ON')
  60.   else
  61.     WriteLn('ofF');
  62.  
  63.   Write('Scroll Lock: ');
  64.   if (Kb and ScrollState) = ScrollState then
  65.     WriteLn('ON')
  66.   else
  67.     WriteLn('ofF');
  68. end.
  69.  
  70. {
  71. This Program will toggle, Turn on, or Turn off the Caps Lock, Num
  72. Lock, and Scroll Lock lights. and when its done it tells you the
  73. state of each key.
  74. }
  75.